<%@ page pageEncoding="UTF-8"%>
<%@ include file="../common/header.jsp"%>
<!-- 修改表单  -->
<div id="form-window-update" style="padding: 15px">
	<form id="form-data-update" action="${ctx}/category?opt=doUpdate" method="post">
	    <!-- 类目ID -->
		<input type="hidden" class="form-control" name="id" value="${category.id}">
		<div class="form-group">
			<label>类目名称</label> <input type="text" class="form-control" name="name" value="${category.name}">
		</div>
		<div class="form-group">
			<label>类目参数</label> <input type="text" class="form-control" name="param" value="${category.param}">
		</div>
		<div class="form-group">
			<label>类目图片</label>
			<jsp:include page="../common/file_upload_v1.jsp"></jsp:include>
		</div>
		<div class="form-group pull-right">
		    <input id="btn-update-do" type="submit" class="btn btn-primary btn-do" value="保存">
			<input type="button" class="btn btn-default btn-close" value="关闭" onclick="parent.layer.closeAll();">
		</div>
	</form>
</div>
<script>
//修改
$('#form-data-update').bootstrapValidator({
	fields : {
		name : {
			validators : {
				notEmpty : {
					message : '类目名称不能为空'
				}
			}
		},
		param : {
			validators : {
				notEmpty : {
					message : '类目参数不能为空'
				}
			}
		}
	}
}).on('success.form.bv', function(e) {//点击提交之后
	//阻止表单提交的默认事件
	e.preventDefault();
	//获取表单
	var $form = $(e.target);
	//异步提交表单
	$form.ajaxSubmit(function(result) {
		//将字符串转换为json对象
		var data = JSON.parse(result);
		if (data.status == 0) {
			layer.alert(data.msg, function(index) {
				//刷新列表的内容
				$('.load-data').click();
				parent.layer.closeAll();
			});
		} else {
			layer.alert(data.msg);
			$('.btn-do').removeAttr("disabled");
		}
	});
});
</script>
<%@ include file="../common/footer.jsp"%>	